<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/gui/graphicsview/qgraphicsscene.cpp -->
<head>
  <title>Qt 4.3: QGraphicsScene Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QGraphicsScene Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QGraphicsScene class provides a surface for managing a large number of 2D graphical items. <a href="#details">More...</a></p>
<pre> #include &lt;QGraphicsScene&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<p>This class was introduced in Qt 4.2.</p>
<ul>
<li><a href="qgraphicsscene-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>enum <b><a href="qgraphicsscene.html#ItemIndexMethod-enum">ItemIndexMethod</a></b> { BspTreeIndex, NoIndex }</li>
<li><div class="fn"/>enum <b><a href="qgraphicsscene.html#SceneLayer-enum">SceneLayer</a></b> { ItemLayer, BackgroundLayer, ForegroundLayer, AllLayers }</li>
<li><div class="fn"/>flags <b><a href="qgraphicsscene.html#SceneLayer-enum">SceneLayers</a></b></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="45%" valign="top"><ul>
<li><div class="fn"/><b><a href="qgraphicsscene.html#backgroundBrush-prop">backgroundBrush</a></b> : QBrush</li>
<li><div class="fn"/><b><a href="qgraphicsscene.html#bspTreeDepth-prop">bspTreeDepth</a></b> : int</li>
<li><div class="fn"/><b><a href="qgraphicsscene.html#foregroundBrush-prop">foregroundBrush</a></b> : QBrush</li>
</ul></td><td valign="top"><ul>
<li><div class="fn"/><b><a href="qgraphicsscene.html#itemIndexMethod-prop">itemIndexMethod</a></b> : ItemIndexMethod</li>
<li><div class="fn"/><b><a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a></b> : QRectF</li>
</ul>
</td></tr>
</table></p>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qgraphicsscene.html#QGraphicsScene">QGraphicsScene</a></b> ( QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qgraphicsscene.html#QGraphicsScene-2">QGraphicsScene</a></b> ( const QRectF &amp; <i>sceneRect</i>, QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qgraphicsscene.html#QGraphicsScene-3">QGraphicsScene</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>width</i>, qreal <i>height</i>, QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/>virtual <b><a href="qgraphicsscene.html#dtor.QGraphicsScene">~QGraphicsScene</a></b> ()</li>
<li><div class="fn"/>QGraphicsEllipseItem * <b><a href="qgraphicsscene.html#addEllipse">addEllipse</a></b> ( const QRectF &amp; <i>rect</i>, const QPen &amp; <i>pen</i> = QPen(), const QBrush &amp; <i>brush</i> = QBrush() )</li>
<li><div class="fn"/>QGraphicsEllipseItem * <b><a href="qgraphicsscene.html#addEllipse-2">addEllipse</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i>, const QPen &amp; <i>pen</i> = QPen(), const QBrush &amp; <i>brush</i> = QBrush() )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#addItem">addItem</a></b> ( QGraphicsItem * <i>item</i> )</li>
<li><div class="fn"/>QGraphicsLineItem * <b><a href="qgraphicsscene.html#addLine">addLine</a></b> ( const QLineF &amp; <i>line</i>, const QPen &amp; <i>pen</i> = QPen() )</li>
<li><div class="fn"/>QGraphicsLineItem * <b><a href="qgraphicsscene.html#addLine-2">addLine</a></b> ( qreal <i>x1</i>, qreal <i>y1</i>, qreal <i>x2</i>, qreal <i>y2</i>, const QPen &amp; <i>pen</i> = QPen() )</li>
<li><div class="fn"/>QGraphicsPathItem * <b><a href="qgraphicsscene.html#addPath">addPath</a></b> ( const QPainterPath &amp; <i>path</i>, const QPen &amp; <i>pen</i> = QPen(), const QBrush &amp; <i>brush</i> = QBrush() )</li>
<li><div class="fn"/>QGraphicsPixmapItem * <b><a href="qgraphicsscene.html#addPixmap">addPixmap</a></b> ( const QPixmap &amp; <i>pixmap</i> )</li>
<li><div class="fn"/>QGraphicsPolygonItem * <b><a href="qgraphicsscene.html#addPolygon">addPolygon</a></b> ( const QPolygonF &amp; <i>polygon</i>, const QPen &amp; <i>pen</i> = QPen(), const QBrush &amp; <i>brush</i> = QBrush() )</li>
<li><div class="fn"/>QGraphicsRectItem * <b><a href="qgraphicsscene.html#addRect">addRect</a></b> ( const QRectF &amp; <i>rect</i>, const QPen &amp; <i>pen</i> = QPen(), const QBrush &amp; <i>brush</i> = QBrush() )</li>
<li><div class="fn"/>QGraphicsRectItem * <b><a href="qgraphicsscene.html#addRect-2">addRect</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i>, const QPen &amp; <i>pen</i> = QPen(), const QBrush &amp; <i>brush</i> = QBrush() )</li>
<li><div class="fn"/>QGraphicsSimpleTextItem * <b><a href="qgraphicsscene.html#addSimpleText">addSimpleText</a></b> ( const QString &amp; <i>text</i>, const QFont &amp; <i>font</i> = QFont() )</li>
<li><div class="fn"/>QGraphicsTextItem * <b><a href="qgraphicsscene.html#addText">addText</a></b> ( const QString &amp; <i>text</i>, const QFont &amp; <i>font</i> = QFont() )</li>
<li><div class="fn"/>QBrush <b><a href="qgraphicsscene.html#backgroundBrush-prop">backgroundBrush</a></b> () const</li>
<li><div class="fn"/>int <b><a href="qgraphicsscene.html#bspTreeDepth-prop">bspTreeDepth</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#clearFocus">clearFocus</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#clearSelection">clearSelection</a></b> ()</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#collidingItems">collidingItems</a></b> ( const QGraphicsItem * <i>item</i>, Qt::ItemSelectionMode <i>mode</i> = Qt::IntersectsItemShape ) const</li>
<li><div class="fn"/>QGraphicsItemGroup * <b><a href="qgraphicsscene.html#createItemGroup">createItemGroup</a></b> ( const QList&lt;QGraphicsItem *&gt; &amp; <i>items</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#destroyItemGroup">destroyItemGroup</a></b> ( QGraphicsItemGroup * <i>group</i> )</li>
<li><div class="fn"/>QGraphicsItem * <b><a href="qgraphicsscene.html#focusItem">focusItem</a></b> () const</li>
<li><div class="fn"/>QBrush <b><a href="qgraphicsscene.html#foregroundBrush-prop">foregroundBrush</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qgraphicsscene.html#hasFocus">hasFocus</a></b> () const</li>
<li><div class="fn"/>qreal <b><a href="qgraphicsscene.html#height">height</a></b> () const</li>
<li><div class="fn"/>virtual QVariant <b><a href="qgraphicsscene.html#inputMethodQuery">inputMethodQuery</a></b> ( Qt::InputMethodQuery <i>query</i> ) const</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#invalidate-2">invalidate</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i>, SceneLayers <i>layers</i> = AllLayers )</li>
<li><div class="fn"/>QGraphicsItem * <b><a href="qgraphicsscene.html#itemAt">itemAt</a></b> ( const QPointF &amp; <i>position</i> ) const</li>
<li><div class="fn"/>QGraphicsItem * <b><a href="qgraphicsscene.html#itemAt-2">itemAt</a></b> ( qreal <i>x</i>, qreal <i>y</i> ) const</li>
<li><div class="fn"/>ItemIndexMethod <b><a href="qgraphicsscene.html#itemIndexMethod-prop">itemIndexMethod</a></b> () const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#items">items</a></b> () const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#items-2">items</a></b> ( const QPointF &amp; <i>pos</i> ) const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#items-3">items</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i>, Qt::ItemSelectionMode <i>mode</i> = Qt::IntersectsItemShape ) const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#items-4">items</a></b> ( const QRectF &amp; <i>rectangle</i>, Qt::ItemSelectionMode <i>mode</i> = Qt::IntersectsItemShape ) const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#items-5">items</a></b> ( const QPolygonF &amp; <i>polygon</i>, Qt::ItemSelectionMode <i>mode</i> = Qt::IntersectsItemShape ) const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#items-6">items</a></b> ( const QPainterPath &amp; <i>path</i>, Qt::ItemSelectionMode <i>mode</i> = Qt::IntersectsItemShape ) const</li>
<li><div class="fn"/>QRectF <b><a href="qgraphicsscene.html#itemsBoundingRect">itemsBoundingRect</a></b> () const</li>
<li><div class="fn"/>QGraphicsItem * <b><a href="qgraphicsscene.html#mouseGrabberItem">mouseGrabberItem</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#removeItem">removeItem</a></b> ( QGraphicsItem * <i>item</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#render">render</a></b> ( QPainter * <i>painter</i>, const QRectF &amp; <i>target</i> = QRectF(), const QRectF &amp; <i>source</i> = QRectF(), Qt::AspectRatioMode <i>aspectRatioMode</i> = Qt::KeepAspectRatio )</li>
<li><div class="fn"/>QRectF <b><a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a></b> () const</li>
<li><div class="fn"/>QList&lt;QGraphicsItem *&gt; <b><a href="qgraphicsscene.html#selectedItems">selectedItems</a></b> () const</li>
<li><div class="fn"/>QPainterPath <b><a href="qgraphicsscene.html#selectionArea">selectionArea</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#backgroundBrush-prop">setBackgroundBrush</a></b> ( const QBrush &amp; <i>brush</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#bspTreeDepth-prop">setBspTreeDepth</a></b> ( int <i>depth</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#setFocus">setFocus</a></b> ( Qt::FocusReason <i>focusReason</i> = Qt::OtherFocusReason )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#setFocusItem">setFocusItem</a></b> ( QGraphicsItem * <i>item</i>, Qt::FocusReason <i>focusReason</i> = Qt::OtherFocusReason )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#foregroundBrush-prop">setForegroundBrush</a></b> ( const QBrush &amp; <i>brush</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#itemIndexMethod-prop">setItemIndexMethod</a></b> ( ItemIndexMethod <i>method</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#sceneRect-prop">setSceneRect</a></b> ( const QRectF &amp; <i>rect</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#sceneRect-prop">setSceneRect</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a></b> ( const QPainterPath &amp; <i>path</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#setSelectionArea-2">setSelectionArea</a></b> ( const QPainterPath &amp; <i>path</i>, Qt::ItemSelectionMode <i>mode</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#update">update</a></b> ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i> )</li>
<li><div class="fn"/>QList&lt;QGraphicsView *&gt; <b><a href="qgraphicsscene.html#views">views</a></b> () const</li>
<li><div class="fn"/>qreal <b><a href="qgraphicsscene.html#width">width</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#advance">advance</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#invalidate">invalidate</a></b> ( const QRectF &amp; <i>rect</i> = QRectF(), SceneLayers <i>layers</i> = AllLayers )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#update-2">update</a></b> ( const QRectF &amp; <i>rect</i> = QRectF() )</li>
</ul>
<ul>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#changed">changed</a></b> ( const QList&lt;QRectF&gt; &amp; <i>region</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#sceneRectChanged">sceneRectChanged</a></b> ( const QRectF &amp; <i>rect</i> )</li>
<li><div class="fn"/>void <b><a href="qgraphicsscene.html#selectionChanged">selectionChanged</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h3>Protected Functions</h3>
<ul>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#contextMenuEvent">contextMenuEvent</a></b> ( QGraphicsSceneContextMenuEvent * <i>contextMenuEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#drawBackground">drawBackground</a></b> ( QPainter * <i>painter</i>, const QRectF &amp; <i>rect</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#drawForeground">drawForeground</a></b> ( QPainter * <i>painter</i>, const QRectF &amp; <i>rect</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#drawItems">drawItems</a></b> ( QPainter * <i>painter</i>, int <i>numItems</i>, QGraphicsItem *[] <i>items</i>, const QStyleOptionGraphicsItem[] <i>options</i>, QWidget * <i>widget</i> = 0 )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#dropEvent">dropEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</li>
<li><div class="fn"/>virtual bool <b><a href="qgraphicsscene.html#event">event</a></b> ( QEvent * <i>event</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#focusInEvent">focusInEvent</a></b> ( QFocusEvent * <i>focusEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#focusOutEvent">focusOutEvent</a></b> ( QFocusEvent * <i>focusEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#helpEvent">helpEvent</a></b> ( QGraphicsSceneHelpEvent * <i>helpEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#inputMethodEvent">inputMethodEvent</a></b> ( QInputMethodEvent * <i>event</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>keyEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#keyReleaseEvent">keyReleaseEvent</a></b> ( QKeyEvent * <i>keyEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a></b> ( QGraphicsSceneMouseEvent * <i>mouseEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#mouseMoveEvent">mouseMoveEvent</a></b> ( QGraphicsSceneMouseEvent * <i>mouseEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a></b> ( QGraphicsSceneMouseEvent * <i>mouseEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#mouseReleaseEvent">mouseReleaseEvent</a></b> ( QGraphicsSceneMouseEvent * <i>mouseEvent</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qgraphicsscene.html#wheelEvent">wheelEvent</a></b> ( QGraphicsSceneWheelEvent * <i>wheelEvent</i> )</li>
</ul>
<ul>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.</p>
<p>The class serves as a container for QGraphicsItems. It is used together with <a href="qgraphicsview.html">QGraphicsView</a> for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is part of <a href="graphicsview.html">The Graphics View Framework</a>.</p>
<p>QGraphicsScene also provides functionality that lets you efficiently determine both the location of items, and for determining what items are visible within an arbitrary area on the scene. With the <a href="qgraphicsview.html">QGraphicsView</a> widget, you can either visualize the whole scene, or zoom in and view only parts of the scene.</p>
<p>Example:</p>
<pre> QGraphicsScene scene;
 scene.addText(&quot;Hello, world!&quot;);

 QGraphicsView view(&amp;scene);
 view.show();</pre>
<p>Note that QGraphicsScene has no visual appearance of its own; it only manages the items. You need to create a <a href="qgraphicsview.html">QGraphicsView</a> widget to visualize the scene.</p>
<p>To add items to a scene, you start off by constructing a QGraphicsScene object. Then, you have two options: either add your existing <a href="qgraphicsitem.html">QGraphicsItem</a> objects by calling <a href="qgraphicsscene.html#addItem">addItem</a>(), or you can call one of the convenience functions <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPolygon">addPolygon</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), or <a href="qgraphicsscene.html#addText">addText</a>(), which all return a pointer to the newly added item. The dimensions of the items added with these functions are relative to the item's coordinate system, and the items position is initialized to (0, 0) in the scene.</p>
<p>You can then visualize the scene using <a href="qgraphicsview.html">QGraphicsView</a>. When the scene changes, (e.g&#x2e;, when an item moves or is transformed) QGraphicsScene emits the <a href="qgraphicsscene.html#changed">changed</a>() signal. To remove an item, call <a href="qgraphicsscene.html#removeItem">removeItem</a>().</p>
<p>QGraphicsScene uses an indexing algorithm to manage the location of items efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an algorithm suitable for large scenes where most items remain static (i.e&#x2e;, do not move around). You can choose to disable this index by calling <a href="qgraphicsscene.html#itemIndexMethod-prop">setItemIndexMethod</a>(). For more information about the available indexing algorithms, see the <a href="qgraphicsscene.html#itemIndexMethod-prop">itemIndexMethod</a> property.</p>
<p>The scene's bounding rect is set by calling <a href="qgraphicsscene.html#sceneRect-prop">setSceneRect</a>(). Items can be placed at any position on the scene, and the size of the scene is by default unlimited. The scene rect is used only for internal bookkeeping, maintaining the scene's item index. If the scene rect is unset, QGraphicsScene will use the bounding area of all items, as returned by <a href="qgraphicsscene.html#itemsBoundingRect">itemsBoundingRect</a>(), as the scene rect. However, <a href="qgraphicsscene.html#itemsBoundingRect">itemsBoundingRect</a>() is a relatively time consuming function, as it operates by collecting positional information for every item on the scene. Because of this, you should always set the scene rect when operating on large scenes.</p>
<p>One of QGraphicsScene's greatest strengths is its ability to efficiently determine the location of items. Even with millions of items on the scene, the <a href="qgraphicsscene.html#items">items</a>() functions can determine the location of an item within few milliseconds. There are several overloads to <a href="qgraphicsscene.html#items">items</a>(): one that finds items at a certain position, one that finds items inside or intersecting with a polygon or a rectangle, and more. The list of returned items is sorted by stacking order, with the topmost item being the first item in the list. For convenience, there is also an <a href="qgraphicsscene.html#itemAt">itemAt</a>() function that returns the topmost item at a given position.</p>
<p>QGraphicsScene maintains selection information for the scene. To select items, call <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>(), and to clear the current selection, call <a href="qgraphicsscene.html#clearSelection">clearSelection</a>(). Call <a href="qgraphicsscene.html#selectedItems">selectedItems</a>() to get the list of all selected items.</p>
<a name="event-handling-and-propagation"></a>
<h3>Event Handling and Propagation</h3>
<p>Another responsibility that QGraphicsScene has, is to propagate events from <a href="qgraphicsview.html">QGraphicsView</a>. To send an event to a scene, you construct an event that inherits <a href="qevent.html">QEvent</a>, and then send it using, for example, <a href="qcoreapplication.html#sendEvent">QApplication::sendEvent</a>(). <a href="qgraphicsscene.html#event">event</a>() is responsible for dispatching the event to the individual items. Some common events are handled by convenience event handlers. For example, key press events are handled by <a href="qgraphicsscene.html#keyPressEvent">keyPressEvent</a>(), and mouse press events are handled by <a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a>().</p>
<p>Key events are delivered to the <i>focus item</i>. To set the focus item, you can either call <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>(), passing an item that accepts focus, or the item itself can call <a href="qgraphicsitem.html#setFocus">QGraphicsItem::setFocus</a>(). Call <a href="qgraphicsscene.html#focusItem">focusItem</a>() to get the current focus item. For compatibility with widgets, the scene also maintains its own focus information. By default, the scene does not have focus, and all key events are discarded. If <a href="qgraphicsscene.html#setFocus">setFocus</a>() is called, or if an item on the scene gains focus, the scene automatically gains focus. If the scene has focus, <a href="qgraphicsscene.html#hasFocus">hasFocus</a>() will return true, and key events will be forwarded to the focus item, if any. If the scene loses focus, (i.e&#x2e;, someone calls <a href="qgraphicsscene.html#clearFocus">clearFocus</a>(),) while an item has focus, the scene will maintain its item focus information, and once the scene regains focus, it will make sure the last focus item regains focus.</p>
<p>For mouse-over effects, QGraphicsScene dispatches <i>hover events</i>. If an item accepts hover events (see <a href="qgraphicsitem.html#acceptsHoverEvents">QGraphicsItem::acceptsHoverEvents</a>()), it will receive a <a href="qevent.html#Type-enum">GraphicsSceneHoverEnter</a> event when the mouse enters its area. As the mouse continues moving inside the item's area, QGraphicsScene will send it <a href="qevent.html#Type-enum">GraphicsSceneHoverMove</a> events. When the mouse leaves the item's area, the item will receive a <a href="qevent.html#Type-enum">GraphicsSceneHoverLeave</a> event.</p>
<p>All mouse events are delivered to the current <i>mouse grabber</i> item. An item becomes the scene's mouse grabber if it accepts mouse events (see <a href="qgraphicsitem.html#acceptedMouseButtons">QGraphicsItem::acceptedMouseButtons</a>()) and it receives a mouse press. It stays the mouse grabber until it receives a mouse release when no other mouse buttons are pressed. You can call <a href="qgraphicsscene.html#mouseGrabberItem">mouseGrabberItem</a>() to determine what item is currently grabbing the mouse.</p>
<p>See also <a href="qgraphicsitem.html">QGraphicsItem</a> and <a href="qgraphicsview.html">QGraphicsView</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="ItemIndexMethod-enum"></a>enum QGraphicsScene::ItemIndexMethod</h3>
<p>This enum describes the indexing algorithms <a href="qgraphicsscene.html">QGraphicsScene</a> provides for managing positional information about items on the scene.</p>
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QGraphicsScene::BspTreeIndex</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">A Binary Space Partitioning tree is applied. All <a href="qgraphicsscene.html">QGraphicsScene</a>'s item location algorithms are of an order close to logarithmic complexity, by making use of binary search. Adding, moving and removing items is logarithmic. This approach is best for static scenes (i.e&#x2e;, scenes where most items do not move).</td></tr>
<tr><td valign="top"><tt>QGraphicsScene::NoIndex</tt></td><td align="center" valign="top"><tt>-1</tt></td><td valign="top">No index is applied. Item location is of linear complexity, as all items on the scene are searched. Adding, moving and removing items, however, is done in constant time. This approach is ideal for dynamic scenes, where many items are added, moved or removed continuously.</td></tr>
</table></p>
<p>See also <a href="qgraphicsscene.html#itemIndexMethod-prop">setItemIndexMethod</a>() and <a href="qgraphicsscene.html#bspTreeDepth-prop">bspTreeDepth</a>.</p>
<h3 class="flags"><a name="SceneLayer-enum"></a>enum QGraphicsScene::SceneLayer<br />flags QGraphicsScene::SceneLayers</h3>
<p>This enum describes the rendering layers in a <a href="qgraphicsscene.html">QGraphicsScene</a>. When <a href="qgraphicsscene.html">QGraphicsScene</a> draws the scene contents, it renders each of these layers separately, in order.</p>
<p>Each layer represents a flag that can be OR'ed together when calling functions such as <a href="qgraphicsscene.html#invalidate">invalidate</a>() or <a href="qgraphicsview.html#invalidateScene">QGraphicsView::invalidateScene</a>().</p>
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QGraphicsScene::ItemLayer</tt></td><td align="center" valign="top"><tt>0x1</tt></td><td valign="top">The item layer. <a href="qgraphicsscene.html">QGraphicsScene</a> renders all items are in this layer by calling the virtual function <a href="qgraphicsscene.html#drawItems">drawItems</a>(). The item layer is drawn after the background layer, but before the foreground layer.</td></tr>
<tr><td valign="top"><tt>QGraphicsScene::BackgroundLayer</tt></td><td align="center" valign="top"><tt>0x2</tt></td><td valign="top">The background layer. <a href="qgraphicsscene.html">QGraphicsScene</a> renders the scene's background in this layer by calling the virtual function <a href="qgraphicsscene.html#drawBackground">drawBackground</a>(). The background layer is drawn first of all layers.</td></tr>
<tr><td valign="top"><tt>QGraphicsScene::ForegroundLayer</tt></td><td align="center" valign="top"><tt>0x4</tt></td><td valign="top">The foreground layer. <a href="qgraphicsscene.html">QGraphicsScene</a> renders the scene's foreground in this layer by calling the virtual function <a href="qgraphicsscene.html#drawForeground">drawForeground</a>(). The foreground layer is drawn last of all layers.</td></tr>
<tr><td valign="top"><tt>QGraphicsScene::AllLayers</tt></td><td align="center" valign="top"><tt>0xffff</tt></td><td valign="top">All layers; this value represents a combination of all three layers.</td></tr>
</table></p>
<p>This enum was introduced in Qt 4.3.</p>
<p>The SceneLayers type is a typedef for <a href="qflags.html">QFlags</a>&lt;SceneLayer&gt;. It stores an OR combination of SceneLayer values.</p>
<p>See also <a href="qgraphicsscene.html#invalidate">invalidate</a>() and <a href="qgraphicsview.html#invalidateScene">QGraphicsView::invalidateScene</a>().</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="backgroundBrush-prop"></a>backgroundBrush : <a href="qbrush.html">QBrush</a></h3>
<p>This property holds the background brush of the scene.</p>
<p>Set this property to changes the scene's background to a different color, gradient or texture. The default background brush is <a href="qt.html#BrushStyle-enum">Qt::NoBrush</a>. The background is drawn before (behind) the items.</p>
<p>Example:</p>
<pre> QGraphicsScene scene;
 QGraphicsView view(&amp;scene);
 view.show();

<span class="comment"> //</span> a blue background
 scene.setBackgroundBrush(Qt::blue);

<span class="comment"> //</span> a gradient background
 QRadialGradient gradient(0, 0, 10);
 gradient.setSpread(QGradient::RepeatSpread);
 scene.setBackgroundBrush(gradient);</pre>
<p><a href="qgraphicsscene.html#render">QGraphicsScene::render</a>() calls <a href="qgraphicsscene.html#drawBackground">drawBackground</a>() to draw the scene background. For more detailed control over how the background is drawn, you can reimplement <a href="qgraphicsscene.html#drawBackground">drawBackground</a>() in a subclass of <a href="qgraphicsscene.html">QGraphicsScene</a>.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QBrush backgroundBrush () const</b></li>
<li><div class="fn"/><b>void setBackgroundBrush ( const QBrush &amp; <i>brush</i> )</b></li>
</ul>
<h3 class="fn"><a name="bspTreeDepth-prop"></a>bspTreeDepth : int</h3>
<p>This property holds the depth of QGraphicsScene's BSP index tree.</p>
<p>This property has no effect when <a href="qgraphicsscene.html#ItemIndexMethod-enum">NoIndex</a> is used.</p>
<p>This value determines the depth of <a href="qgraphicsscene.html">QGraphicsScene</a>'s BSP tree. The depth directly affects <a href="qgraphicsscene.html">QGraphicsScene</a>'s performance and memory usage; the latter growing exponentially with the depth of the tree. With an optimal tree depth, <a href="qgraphicsscene.html">QGraphicsScene</a> can instantly determine the locality of items, even for scenes with thousands or millions of items. This also greatly improves rendering performance.</p>
<p>By default, the value is 0, in which case Qt will guess a reasonable default depth based on the size, location and number of items in the scene. If these parameters change frequently, however, you may experience slowdowns as <a href="qgraphicsscene.html">QGraphicsScene</a> retunes the depth internally. You can avoid potential slowdowns by fixating the tree depth through setting this property.</p>
<p>The depth of the tree and the size of the scene rectangle decide the granularity of the scene's partitioning. The size of each scene segment is determined by the following algorithm:</p>
<pre> QSizeF segmentSize = sceneRect().size() / pow(2, depth - 1);</pre>
<p>The BSP tree has an optimal size when each segment contains between 0 and 10 items.</p>
<p>This property was introduced in Qt 4.3.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>int bspTreeDepth () const</b></li>
<li><div class="fn"/><b>void setBspTreeDepth ( int <i>depth</i> )</b></li>
</ul>
<p>See also <a href="qgraphicsscene.html#itemIndexMethod-prop">itemIndexMethod</a>.</p>
<h3 class="fn"><a name="foregroundBrush-prop"></a>foregroundBrush : <a href="qbrush.html">QBrush</a></h3>
<p>This property holds the foreground brush of the scene.</p>
<p>Change this property to set the scene's foreground to a different color, gradient or texture.</p>
<p>The foreground is drawn after (on top of) the items. The default foreground brush is <a href="qt.html#BrushStyle-enum">Qt::NoBrush</a> ( i.e&#x2e; the foreground is not drawn).</p>
<p>Example:</p>
<pre> QGraphicsScene scene;
 QGraphicsView view(&amp;scene);
 view.show();

<span class="comment"> //</span> a white semi-transparent foreground
 scene.setForegroundBrush(QColor(255, 255, 255, 127));

<span class="comment"> //</span> a grid foreground
 scene.setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));</pre>
<p><a href="qgraphicsscene.html#render">QGraphicsScene::render</a>() calls <a href="qgraphicsscene.html#drawForeground">drawForeground</a>() to draw the scene foreground. For more detailed control over how the foreground is drawn, you can reimplement the <a href="qgraphicsscene.html#drawForeground">drawForeground</a>() function in a <a href="qgraphicsscene.html">QGraphicsScene</a> subclass.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QBrush foregroundBrush () const</b></li>
<li><div class="fn"/><b>void setForegroundBrush ( const QBrush &amp; <i>brush</i> )</b></li>
</ul>
<h3 class="fn"><a name="itemIndexMethod-prop"></a>itemIndexMethod : <a href="qgraphicsscene.html#ItemIndexMethod-enum">ItemIndexMethod</a></h3>
<p>This property holds the item indexing method.</p>
<p><a href="qgraphicsscene.html">QGraphicsScene</a> applies an indexing algorithm to the scene, to speed up item discovery functions like <a href="qgraphicsscene.html#items">items</a>() and <a href="qgraphicsscene.html#itemAt">itemAt</a>(). Indexing is most efficient for static scenes (i.e&#x2e;, where items don't move around). For dynamic scenes, or scenes with many animated items, the index bookkeeping can outweight the fast lookup speeds.</p>
<p>For the common case, the default index method <a href="qgraphicsscene.html#ItemIndexMethod-enum">BspTreeIndex</a> works fine. If your scene uses many animations and you are experiencing slowness, you can disable indexing by calling <tt>setItemIndexMethod(NoIndex)</tt>.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>ItemIndexMethod itemIndexMethod () const</b></li>
<li><div class="fn"/><b>void setItemIndexMethod ( ItemIndexMethod <i>method</i> )</b></li>
</ul>
<p>See also <a href="qgraphicsscene.html#bspTreeDepth-prop">bspTreeDepth</a>.</p>
<h3 class="fn"><a name="sceneRect-prop"></a>sceneRect : <a href="qrectf.html">QRectF</a></h3>
<p>This property holds the scene rectangle; the bounding rectangle of the scene.</p>
<p>The scene rectangle defines the extent of the scene. It is primarily used by <a href="qgraphicsview.html">QGraphicsView</a> to determine the view's default scrollable area, and by <a href="qgraphicsscene.html">QGraphicsScene</a> to manage item indexing.</p>
<p>If unset, or if set to a null <a href="qrectf.html">QRectF</a>, sceneRect() will return the largest bounding rect of all items on the scene since the scene was created (i.e&#x2e;, a rectangle that grows when items are added to or moved in the scene, but never shrinks).</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QRectF sceneRect () const</b></li>
<li><div class="fn"/><b>void setSceneRect ( const QRectF &amp; <i>rect</i> )</b></li>
<li><div class="fn"/><b>void setSceneRect ( qreal <i>x</i>, qreal <i>y</i>, qreal <i>w</i>, qreal <i>h</i> )</b></li>
</ul>
<p>See also <a href="qgraphicsscene.html#width">width</a>(), <a href="qgraphicsscene.html#height">height</a>(), and <a href="qgraphicsview.html#sceneRect-prop">QGraphicsView::sceneRect</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QGraphicsScene"></a>QGraphicsScene::QGraphicsScene ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a <a href="qgraphicsscene.html">QGraphicsScene</a> object. The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a>'s constructor.</p>
<h3 class="fn"><a name="QGraphicsScene-2"></a>QGraphicsScene::QGraphicsScene ( const <a href="qrectf.html">QRectF</a> &amp; <i>sceneRect</i>, <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a <a href="qgraphicsscene.html">QGraphicsScene</a> object, using <i>sceneRect</i> for its scene rectangle. The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a>'s constructor.</p>
<p>See also <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>.</p>
<h3 class="fn"><a name="QGraphicsScene-3"></a>QGraphicsScene::QGraphicsScene ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>width</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>height</i>, <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a <a href="qgraphicsscene.html">QGraphicsScene</a> object, using the rectangle specified by (<i>x</i>, <i>y</i>), and the given <i>width</i> and <i>height</i> for its scene rectangle. The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a>'s constructor.</p>
<p>See also <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>.</p>
<h3 class="fn"><a name="dtor.QGraphicsScene"></a>QGraphicsScene::~QGraphicsScene ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Destroys the <a href="qgraphicsscene.html">QGraphicsScene</a> object.</p>
<h3 class="fn"><a name="addEllipse"></a><a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a> * QGraphicsScene::addEllipse ( const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen(), const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> = QBrush() )</h3>
<p>Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by <i>rect</i>, and it's pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p>
<p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addEllipse-2"></a><a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a> * QGraphicsScene::addEllipse ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>w</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>h</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen(), const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> = QBrush() )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This convenience function is equivalent to calling addEllipse(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>pen</i>, <i>brush</i>).</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="addItem"></a>void QGraphicsScene::addItem ( <a href="qgraphicsitem.html">QGraphicsItem</a> * <i>item</i> )</h3>
<p>Adds or moves the item <i>item</i> and all its childen to the scene.</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>If the item is already in a different scene, it will first be removed from its old scene, and then added to this scene as a top-level.</p>
<p>See also <a href="qgraphicsscene.html#removeItem">removeItem</a>(), <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), and <a href="qgraphicsscene.html#addText">addText</a>().</p>
<h3 class="fn"><a name="addLine"></a><a href="qgraphicslineitem.html">QGraphicsLineItem</a> * QGraphicsScene::addLine ( const <a href="qlinef.html">QLineF</a> &amp; <i>line</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen() )</h3>
<p>Creates and adds a line item to the scene, and returns the item pointer. The geometry of the line is defined by <i>line</i>, and it's pen is initialized to <i>pen</i>.</p>
<p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addLine-2"></a><a href="qgraphicslineitem.html">QGraphicsLineItem</a> * QGraphicsScene::addLine ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x1</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y1</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x2</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y2</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen() )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This convenience function is equivalent to calling addLine(<a href="qlinef.html">QLineF</a>(<i>x1</i>, <i>y1</i>, <i>x2</i>, <i>y2</i>), <i>pen</i>).</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="addPath"></a><a href="qgraphicspathitem.html">QGraphicsPathItem</a> * QGraphicsScene::addPath ( const <a href="qpainterpath.html">QPainterPath</a> &amp; <i>path</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen(), const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> = QBrush() )</h3>
<p>Creates and adds a path item to the scene, and returns the item pointer. The geometry of the path is defined by <i>path</i>, and it's pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p>
<p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addPixmap"></a><a href="qgraphicspixmapitem.html">QGraphicsPixmapItem</a> * QGraphicsScene::addPixmap ( const <a href="qpixmap.html">QPixmap</a> &amp; <i>pixmap</i> )</h3>
<p>Creates and adds a pixmap item to the scene, and returns the item pointer. The pixmap is defined by <i>pixmap</i>.</p>
<p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addPolygon"></a><a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a> * QGraphicsScene::addPolygon ( const <a href="qpolygonf.html">QPolygonF</a> &amp; <i>polygon</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen(), const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> = QBrush() )</h3>
<p>Creates and adds a polygon item to the scene, and returns the item pointer. The polygon is defined by <i>polygon</i>, and it's pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p>
<p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addRect"></a><a href="qgraphicsrectitem.html">QGraphicsRectItem</a> * QGraphicsScene::addRect ( const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen(), const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> = QBrush() )</h3>
<p>Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by <i>rect</i>, and it's pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p>
<p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a <a href="qrect.html">QRect</a>(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addRect-2"></a><a href="qgraphicsrectitem.html">QGraphicsRectItem</a> * QGraphicsScene::addRect ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>w</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>h</i>, const <a href="qpen.html">QPen</a> &amp; <i>pen</i> = QPen(), const <a href="qbrush.html">QBrush</a> &amp; <i>brush</i> = QBrush() )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This convenience function is equivalent to calling addRect(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>pen</i>, <i>brush</i>).</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="addSimpleText"></a><a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a> * QGraphicsScene::addSimpleText ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qfont.html">QFont</a> &amp; <i>font</i> = QFont() )</h3>
<p>Creates and adds a <a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a> to the scene, and returns the item pointer. The text string is initialized to <i>text</i>, and it's font is initialized to <i>font</i>.</p>
<p>The item's position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="addText"></a><a href="qgraphicstextitem.html">QGraphicsTextItem</a> * QGraphicsScene::addText ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qfont.html">QFont</a> &amp; <i>font</i> = QFont() )</h3>
<p>Creates and adds a text item to the scene, and returns the item pointer. The text string is initialized to <i>text</i>, and it's font is initialized to <i>font</i>.</p>
<p>The item's position is initialized to (0, 0).</p>
<p>If the item is visible (i.e&#x2e;, <a href="qgraphicsitem.html#isVisible">QGraphicsItem::isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p>
<p>See also <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="advance"></a>void QGraphicsScene::advance ()&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>This slot <i>advances</i> the scene by one step, by calling <a href="qgraphicsitem.html#advance">QGraphicsItem::advance</a>() for all items on the scene. This is done in two phases: in the first phase, all items are notified that the scene is about to change, and in the second phase all items are notified that they can move. In the first phase, <a href="qgraphicsitem.html#advance">QGraphicsItem::advance</a>() is called passing a value of 0 as an argument, and 1 is passed in the second phase.</p>
<p>See also <a href="qgraphicsitem.html#advance">QGraphicsItem::advance</a>(), <a href="qgraphicsitemanimation.html">QGraphicsItemAnimation</a>, and <a href="qtimeline.html">QTimeLine</a>.</p>
<h3 class="fn"><a name="changed"></a>void QGraphicsScene::changed ( const <a href="qlist.html">QList</a>&lt;<a href="qrectf.html">QRectF</a>&gt; &amp; <i>region</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted by <a href="qgraphicsscene.html">QGraphicsScene</a> when control reaches the event loop, if the scene content changes. The <i>region</i> parameter contains a list of scene rectangles that indicate the area that has been changed.</p>
<p>See also <a href="qgraphicsview.html#updateScene">QGraphicsView::updateScene</a>().</p>
<h3 class="fn"><a name="clearFocus"></a>void QGraphicsScene::clearFocus ()</h3>
<p>Clears focus from the scene. If any item has focus when this function is called, it will lose focus, and regain focus again once the scene regains focus.</p>
<p>A scene that does not have focus ignores key events.</p>
<p>See also <a href="qgraphicsscene.html#hasFocus">hasFocus</a>(), <a href="qgraphicsscene.html#setFocus">setFocus</a>(), and <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>().</p>
<h3 class="fn"><a name="clearSelection"></a>void QGraphicsScene::clearSelection ()</h3>
<p>Clears the current selection.</p>
<p>See also <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>() and <a href="qgraphicsscene.html#selectedItems">selectedItems</a>().</p>
<h3 class="fn"><a name="collidingItems"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::collidingItems ( const <a href="qgraphicsitem.html">QGraphicsItem</a> * <i>item</i>, <a href="qt.html#ItemSelectionMode-enum">Qt::ItemSelectionMode</a> <i>mode</i> = Qt::IntersectsItemShape ) const</h3>
<p>Returns a list of all items that collide with <i>item</i>. Collisions are determined by calling <a href="qgraphicsitem.html#collidesWithItem">QGraphicsItem::collidesWithItem</a>(); the collision detection is determined by <i>mode</i>. By default, all items whose shape intersects <i>item</i> or is contained inside <i>item</i>'s shape are returned.</p>
<p>The items are returned in descending Z order (i.e&#x2e;, the first item in the list is the top-most item, and the last item is the bottom-most item).</p>
<p>See also <a href="qgraphicsscene.html#items">items</a>(), <a href="qgraphicsscene.html#itemAt">itemAt</a>(), and <a href="qgraphicsitem.html#collidesWithItem">QGraphicsItem::collidesWithItem</a>().</p>
<h3 class="fn"><a name="contextMenuEvent"></a>void QGraphicsScene::contextMenuEvent ( <a href="qgraphicsscenecontextmenuevent.html">QGraphicsSceneContextMenuEvent</a> * <i>contextMenuEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>contextMenuEvent</i>, can be reimplemented in a subclass to receive context menu events. The default implementation forwards the event to the item at the scene position provided by the event.</p>
<p>See also <a href="qgraphicsitem.html#contextMenuEvent">QGraphicsItem::contextMenuEvent</a>().</p>
<h3 class="fn"><a name="createItemGroup"></a><a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a> * QGraphicsScene::createItemGroup ( const <a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; &amp; <i>items</i> )</h3>
<p>Groups all items in <i>items</i> into a new <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>, and returns a pointer to the group. The group is created with the common ancestor of <i>items</i> as its parent, and with position (0, 0). The items are all reparented to the group, and their positions and transformations are mapped to the group. If <i>items</i> is empty, this function will return an empty top-level <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>.</p>
<p><a href="qgraphicsscene.html">QGraphicsScene</a> has ownership of the group item; you do not need to delete it. To dismantle (ungroup) a group, call <a href="qgraphicsscene.html#destroyItemGroup">destroyItemGroup</a>().</p>
<p>See also <a href="qgraphicsscene.html#destroyItemGroup">destroyItemGroup</a>() and <a href="qgraphicsitemgroup.html#addToGroup">QGraphicsItemGroup::addToGroup</a>().</p>
<h3 class="fn"><a name="destroyItemGroup"></a>void QGraphicsScene::destroyItemGroup ( <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a> * <i>group</i> )</h3>
<p>Reparents all items in <i>group</i> to <i>group</i>'s parent item, then removes <i>group</i> from the scene, and finally deletes it. The items' positions and transformations are mapped from the group to the group's parent.</p>
<p>See also <a href="qgraphicsscene.html#createItemGroup">createItemGroup</a>() and <a href="qgraphicsitemgroup.html#removeFromGroup">QGraphicsItemGroup::removeFromGroup</a>().</p>
<h3 class="fn"><a name="dragEnterEvent"></a>void QGraphicsScene::dragEnterEvent ( <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drag enter events for the scene.</p>
<p>The default implementation accepts the event and prepares the scene to accept drag move events.</p>
<p>See also <a href="qgraphicsitem.html#dragEnterEvent">QGraphicsItem::dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a>(), <a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a>(), and <a href="qgraphicsscene.html#dropEvent">dropEvent</a>().</p>
<h3 class="fn"><a name="dragLeaveEvent"></a>void QGraphicsScene::dragLeaveEvent ( <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drag leave events for the scene.</p>
<p>See also <a href="qgraphicsitem.html#dragLeaveEvent">QGraphicsItem::dragLeaveEvent</a>(), <a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a>(), and <a href="qgraphicsscene.html#dropEvent">dropEvent</a>().</p>
<h3 class="fn"><a name="dragMoveEvent"></a>void QGraphicsScene::dragMoveEvent ( <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drag move events for the scene.</p>
<p>See also <a href="qgraphicsitem.html#dragMoveEvent">QGraphicsItem::dragMoveEvent</a>(), <a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a>(), and <a href="qgraphicsscene.html#dropEvent">dropEvent</a>().</p>
<h3 class="fn"><a name="drawBackground"></a>void QGraphicsScene::drawBackground ( <a href="qpainter.html">QPainter</a> * <i>painter</i>, const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Draws the background of the scene using <i>painter</i>, before any items and the foreground are drawn. Reimplement this function to provide a custom background for the scene.</p>
<p>All painting is done in <i>scene</i> coordinates. The <i>rect</i> parameter is the exposed rectangle.</p>
<p>If all you want is to define a color, texture, or gradient for the background, you can call <a href="qgraphicsscene.html#backgroundBrush-prop">setBackgroundBrush</a>() instead.</p>
<p>See also <a href="qgraphicsscene.html#drawForeground">drawForeground</a>() and <a href="qgraphicsscene.html#drawItems">drawItems</a>().</p>
<h3 class="fn"><a name="drawForeground"></a>void QGraphicsScene::drawForeground ( <a href="qpainter.html">QPainter</a> * <i>painter</i>, const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Draws the foreground of the scene using <i>painter</i>, after the background and all items have been drawn. Reimplement this function to provide a custom foreground for the scene.</p>
<p>All painting is done in <i>scene</i> coordinates. The <i>rect</i> parameter is the exposed rectangle.</p>
<p>If all you want is to define a color, texture or gradient for the foreground, you can call <a href="qgraphicsscene.html#foregroundBrush-prop">setForegroundBrush</a>() instead.</p>
<p>See also <a href="qgraphicsscene.html#drawBackground">drawBackground</a>() and <a href="qgraphicsscene.html#drawItems">drawItems</a>().</p>
<h3 class="fn"><a name="drawItems"></a>void QGraphicsScene::drawItems ( <a href="qpainter.html">QPainter</a> * <i>painter</i>, int <i>numItems</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> *[] <i>items</i>, const <a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a>[] <i>options</i>, <a href="qwidget.html">QWidget</a> * <i>widget</i> = 0 )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Paints the given <i>items</i> using the provided <i>painter</i>, after the background has been drawn, and before the foreground has been drawn. All painting is done in <i>scene</i> coordinates. Before drawing each item, the painter must be transformed using <a href="qgraphicsitem-obsolete.html#sceneMatrix">QGraphicsItem::sceneMatrix</a>().</p>
<p>The <i>options</i> parameter is the list of style option objects for each item in <i>items</i>. The <i>numItems</i> parameter is the number of items in <i>items</i> and options in <i>options</i>. The <i>widget</i> parameter is optional; if specified, it should point to the widget that is being painted on.</p>
<p>The default implementation prepares the painter matrix, and calls <a href="qgraphicsitem.html#paint">QGraphicsItem::paint</a>() on all items. Reimplement this function to provide custom painting of all items for the scene; gaining complete control over how each item is drawn. In some cases this can increase drawing performance significantly.</p>
<p>Example:</p>
<pre> void CustomScene::drawItems(QPainter *painter, int numItems,
                             QGraphicsItem *items[],
                             const QStyleOptionGraphicsItem options[],
                             QWidget *widget)
 {
     for (int i = 0; i &lt; numItems; ++i) {
          <span class="comment">//</span> Draw the item
          painter-&gt;save();
          painter-&gt;setMatrix(items[i]-&gt;sceneMatrix(), true);
          items[i]-&gt;paint(painter, &amp;options[i], widget);
          painter-&gt;restore();
      }
 }</pre>
<p>See also <a href="qgraphicsscene.html#drawBackground">drawBackground</a>() and <a href="qgraphicsscene.html#drawForeground">drawForeground</a>().</p>
<h3 class="fn"><a name="dropEvent"></a>void QGraphicsScene::dropEvent ( <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drop events for the scene.</p>
<p>See also <a href="qgraphicsitem.html#dropEvent">QGraphicsItem::dropEvent</a>(), <a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a>(), and <a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a>().</p>
<h3 class="fn"><a name="event"></a>bool QGraphicsScene::event ( <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Processes the event <i>event</i>, and dispatches it to the respective event handlers.</p>
<p>In addition to calling the convenience event handlers, this function is responsible for converting mouse move events to hover events for when there is no mouse grabber item. Hover events are delivered directly to items; there is no convenience function for them.</p>
<p>Reimplemented from <a href="qobject.html#event">QObject</a>.</p>
<p>See also <a href="qgraphicsscene.html#contextMenuEvent">contextMenuEvent</a>(), <a href="qgraphicsscene.html#keyPressEvent">keyPressEvent</a>(), <a href="qgraphicsscene.html#keyReleaseEvent">keyReleaseEvent</a>(), <a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a>(), <a href="qgraphicsscene.html#mouseMoveEvent">mouseMoveEvent</a>(), <a href="qgraphicsscene.html#mouseReleaseEvent">mouseReleaseEvent</a>(), <a href="qgraphicsscene.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a>(), <a href="qgraphicsscene.html#focusInEvent">focusInEvent</a>(), and <a href="qgraphicsscene.html#focusOutEvent">focusOutEvent</a>().</p>
<h3 class="fn"><a name="focusInEvent"></a>void QGraphicsScene::focusInEvent ( <a href="qfocusevent.html">QFocusEvent</a> * <i>focusEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>focusEvent</i>, can be reimplemented in a subclass to receive focus in events.</p>
<p>The default implementation sets focus on the scene, and then on the last focus item.</p>
<p>See also <a href="qgraphicsitem.html#focusOutEvent">QGraphicsItem::focusOutEvent</a>().</p>
<h3 class="fn"><a name="focusItem"></a><a href="qgraphicsitem.html">QGraphicsItem</a> * QGraphicsScene::focusItem () const</h3>
<p>Returns the scene's current focus item, or 0 if no item currently has focus.</p>
<p>The focus item receives keyboard input when the scene receives a key event.</p>
<p>See also <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>() and <a href="qgraphicsitem.html#hasFocus">QGraphicsItem::hasFocus</a>().</p>
<h3 class="fn"><a name="focusOutEvent"></a>void QGraphicsScene::focusOutEvent ( <a href="qfocusevent.html">QFocusEvent</a> * <i>focusEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>focusEvent</i>, can be reimplemented in a subclass to receive focus out events.</p>
<p>The default implementation removes focus from any focus item, then removes focus from the scene.</p>
<p>See also <a href="qgraphicsitem.html#focusInEvent">QGraphicsItem::focusInEvent</a>().</p>
<h3 class="fn"><a name="hasFocus"></a>bool QGraphicsScene::hasFocus () const</h3>
<p>Returns true if the scene has focus; otherwise returns false. If the scene has focus, it will will forward key events from <a href="qkeyevent.html">QKeyEvent</a> to any item that has focus.</p>
<p>See also <a href="qgraphicsscene.html#setFocus">setFocus</a>() and <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>().</p>
<h3 class="fn"><a name="height"></a><a href="qtglobal.html#qreal-typedef">qreal</a> QGraphicsScene::height () const</h3>
<p>This convenience function is equivalent to calling <tt>sceneRect().height()</tt>.</p>
<p>See also <a href="qgraphicsscene.html#width">width</a>().</p>
<h3 class="fn"><a name="helpEvent"></a>void QGraphicsScene::helpEvent ( <a href="qgraphicsscenehelpevent.html">QGraphicsSceneHelpEvent</a> * <i>helpEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>helpEvent</i>, can be reimplemented in a subclass to receive help events. The events are of type <a href="qevent.html#Type-enum">QEvent::ToolTip</a>, which are created when a tooltip is requested.</p>
<p>The default implementation shows the tooltip of the topmost item, i.e&#x2e;, the item with the highest z-value, at the mouse cursor position. If no item has a tooltip set, this function does nothing.</p>
<p>See also <a href="qgraphicsitem.html#toolTip">QGraphicsItem::toolTip</a>() and <a href="qgraphicsscenehelpevent.html">QGraphicsSceneHelpEvent</a>.</p>
<h3 class="fn"><a name="inputMethodEvent"></a>void QGraphicsScene::inputMethodEvent ( <a href="qinputmethodevent.html">QInputMethodEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive input method events for the scene.</p>
<p>The default implementation forwards the event to the <a href="qgraphicsscene.html#focusItem">focusItem</a>(). If no item currently has focus, this function does nothing.</p>
<p>See also <a href="qgraphicsitem.html#inputMethodEvent">QGraphicsItem::inputMethodEvent</a>().</p>
<h3 class="fn"><a name="inputMethodQuery"></a><a href="qvariant.html">QVariant</a> QGraphicsScene::inputMethodQuery ( <a href="qt.html#InputMethodQuery-enum">Qt::InputMethodQuery</a> <i>query</i> ) const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>This method is used by input methods to query a set of properties of the scene to be able to support complex input method operations as support for surrounding text and reconversions.</p>
<p>The <i>query</i> parameter specifies which property is queried.</p>
<p>See also <a href="qwidget.html#inputMethodQuery">QWidget::inputMethodQuery</a>().</p>
<h3 class="fn"><a name="invalidate"></a>void QGraphicsScene::invalidate ( const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i> = QRectF(), <a href="qgraphicsscene.html#SceneLayer-enum">SceneLayers</a> <i>layers</i> = AllLayers )&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>Invalidates and schedules a redraw of the <i>layers</i> in <i>rect</i> on the scene. Any cached content in <i>layers</i> is unconditionally invalidated and redrawn.</p>
<p>You can use this function overload to notify <a href="qgraphicsscene.html">QGraphicsScene</a> of changes to the background or the foreground of the scene. This function is commonly used for scenes with tile-based backgrounds to notify changes when <a href="qgraphicsview.html">QGraphicsView</a> has enabled <a href="qgraphicsview.html#CacheModeFlag-enum">CacheBackground</a>.</p>
<p>Example:</p>
<pre> QRectF TileScene::rectForTile(int x, int y) const
 {
     <span class="comment">//</span> Return the rectangle for the tile at position (x, y).
     return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
 }

 void TileScene::setTile(int x, int y, const QPixmap &amp;pixmap)
 {
     <span class="comment">//</span> Sets or replaces the tile at position (x, y) with pixmap.
     if (x &gt;= 0 &amp;&amp; x &lt; numTilesH &amp;&amp; y &gt;= 0 &amp;&amp; y &lt; numTilesV) {
         tiles[y][x] = pixmap;
         invalidate(rectForTile(x, y), BackgroundLayer);
     }
 }

 void TileScene::drawBackground(QPainter *painter, const QRectF &amp;exposed)
 {
     <span class="comment">//</span> Draws all tiles that intersect the exposed area.
     for (int y = 0; y &lt; numTilesV; ++y) {
         for (int x = 0; x &lt; numTilesH; ++x) {
             QRectF rect = rectForTile(x, y);
             if (exposed.intersects(rect))
                 painter-&gt;drawPixmap(rect.topLeft(), tiles[y][x]);
         }
     }
 }</pre>
<p>Note that <a href="qgraphicsview.html">QGraphicsView</a> currently supports background caching only (see <a href="qgraphicsview.html#CacheModeFlag-enum">QGraphicsView::CacheBackground</a>). This function is equivalent to calling <a href="qgraphicsscene.html#update">update</a>() if any layer but <a href="qgraphicsscene.html#SceneLayer-enum">BackgroundLayer</a> is passed.</p>
<p>See also <a href="qgraphicsview.html#resetCachedContent">QGraphicsView::resetCachedContent</a>().</p>
<h3 class="fn"><a name="invalidate-2"></a>void QGraphicsScene::invalidate ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>w</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>h</i>, <a href="qgraphicsscene.html#SceneLayer-enum">SceneLayers</a> <i>layers</i> = AllLayers )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This convenience function is equivalent to calling invalidate(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>layers</i>);</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="itemAt"></a><a href="qgraphicsitem.html">QGraphicsItem</a> * QGraphicsScene::itemAt ( const <a href="qpointf.html">QPointF</a> &amp; <i>position</i> ) const</h3>
<p>Returns the topmost visible item at the specified <i>position</i>, or 0 if there are no items at this position.</p>
<p>See also <a href="qgraphicsscene.html#items">items</a>() and <a href="qgraphicsscene.html#collidingItems">collidingItems</a>().</p>
<h3 class="fn"><a name="itemAt-2"></a><a href="qgraphicsitem.html">QGraphicsItem</a> * QGraphicsScene::itemAt ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns the topmost item at the position specified by (<i>x</i>, <i>y</i>), or 0 if there are no items at this position.</p>
<p>This convenience function is equivalent to calling <tt>itemAt(QPointF(x, y))</tt>.</p>
<h3 class="fn"><a name="items"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::items () const</h3>
<p>Returns a list of all items on the scene, in no particular order.</p>
<p>See also <a href="qgraphicsscene.html#addItem">addItem</a>() and <a href="qgraphicsscene.html#removeItem">removeItem</a>().</p>
<h3 class="fn"><a name="items-2"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::items ( const <a href="qpointf.html">QPointF</a> &amp; <i>pos</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns all visible items at position <i>pos</i> in the scene. The items are listed in descending Z order (i.e&#x2e;, the first item in the list is the top-most item, and the last item is the bottom-most item).</p>
<p>See also <a href="qgraphicsscene.html#itemAt">itemAt</a>().</p>
<h3 class="fn"><a name="items-3"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::items ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>w</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>h</i>, <a href="qt.html#ItemSelectionMode-enum">Qt::ItemSelectionMode</a> <i>mode</i> = Qt::IntersectsItemShape ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>This convenience function is equivalent to calling items(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>mode</i>).</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="items-4"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::items ( const <a href="qrectf.html">QRectF</a> &amp; <i>rectangle</i>, <a href="qt.html#ItemSelectionMode-enum">Qt::ItemSelectionMode</a> <i>mode</i> = Qt::IntersectsItemShape ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns all visible items that, depending on <i>mode</i>, are either inside or intersect with the specified <i>rectangle</i>.</p>
<p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt::IntersectsItemShape</a>; all items whose exact shape intersects with or is contained by <i>rectangle</i> are returned.</p>
<p>See also <a href="qgraphicsscene.html#itemAt">itemAt</a>().</p>
<h3 class="fn"><a name="items-5"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::items ( const <a href="qpolygonf.html">QPolygonF</a> &amp; <i>polygon</i>, <a href="qt.html#ItemSelectionMode-enum">Qt::ItemSelectionMode</a> <i>mode</i> = Qt::IntersectsItemShape ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns all visible items that, depending on <i>mode</i>, are either inside or intersect with the polygon <i>polygon</i>.</p>
<p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt::IntersectsItemShape</a>; all items whose exact shape intersects with or is contained by <i>polygon</i> are returned.</p>
<p>See also <a href="qgraphicsscene.html#itemAt">itemAt</a>().</p>
<h3 class="fn"><a name="items-6"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::items ( const <a href="qpainterpath.html">QPainterPath</a> &amp; <i>path</i>, <a href="qt.html#ItemSelectionMode-enum">Qt::ItemSelectionMode</a> <i>mode</i> = Qt::IntersectsItemShape ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns all visible items that, depending on <i>path</i>, are either inside or intersect with the path <i>path</i>.</p>
<p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt::IntersectsItemShape</a>; all items whose exact shape intersects with or is contained by <i>path</i> are returned.</p>
<p>See also <a href="qgraphicsscene.html#itemAt">itemAt</a>().</p>
<h3 class="fn"><a name="itemsBoundingRect"></a><a href="qrectf.html">QRectF</a> QGraphicsScene::itemsBoundingRect () const</h3>
<p>Calculates and returns the bounding rect of all items on the scene. This function works by iterating over all items, and because if this, it can be slow for large scenes.</p>
<p>See also <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>().</p>
<h3 class="fn"><a name="keyPressEvent"></a>void QGraphicsScene::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * <i>keyEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>keyEvent</i>, can be reimplemented in a subclass to receive keypress events. The default implementation forwards the event to current focus item.</p>
<p>See also <a href="qgraphicsitem.html#keyPressEvent">QGraphicsItem::keyPressEvent</a>() and <a href="qgraphicsscene.html#focusItem">focusItem</a>().</p>
<h3 class="fn"><a name="keyReleaseEvent"></a>void QGraphicsScene::keyReleaseEvent ( <a href="qkeyevent.html">QKeyEvent</a> * <i>keyEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>keyEvent</i>, can be reimplemented in a subclass to receive key release events. The default implementation forwards the event to current focus item.</p>
<p>See also <a href="qgraphicsitem.html#keyReleaseEvent">QGraphicsItem::keyReleaseEvent</a>() and <a href="qgraphicsscene.html#focusItem">focusItem</a>().</p>
<h3 class="fn"><a name="mouseDoubleClickEvent"></a>void QGraphicsScene::mouseDoubleClickEvent ( <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> * <i>mouseEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse doubleclick events for the scene.</p>
<p>If someone doubleclicks on the scene, the scene will first receive a mouse press event, followed by a release event (i.e&#x2e;, a click), then a doubleclick event, and finally a release event. If the doubleclick event is delivered to a different item than the one that received the first press and release, it will be delivered as a press event. However, tripleclick events are not delivered as doubleclick events in this case.</p>
<p>The default implementation is similar to <a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a>().</p>
<p>See also <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem::mousePressEvent</a>(), <a href="qgraphicsitem.html#mouseMoveEvent">QGraphicsItem::mouseMoveEvent</a>(), <a href="qgraphicsitem.html#mouseReleaseEvent">QGraphicsItem::mouseReleaseEvent</a>(), and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem::setAcceptedMouseButtons</a>().</p>
<h3 class="fn"><a name="mouseGrabberItem"></a><a href="qgraphicsitem.html">QGraphicsItem</a> * QGraphicsScene::mouseGrabberItem () const</h3>
<p>Returns the current mouse grabber item, or 0 if no item is currently grabbing the mouse. The mouse grabber item is the item that receives all mouse events sent to the scene.</p>
<p>An item becomes a mouse grabber when it receives and accepts a mouse press event, and it stays the mouse grabber until either of the following events occur:</p>
<ul>
<li>If the item receives a mouse release event when there are no other buttons pressed, it loses the mouse grab.</li>
<li>If the item becomes invisible (i.e&#x2e;, someone calls <tt>item-&gt;setVisible(false))</tt>, or if it becomes disabled (i.e&#x2e;, someone calls <tt>item-&gt;setEnabled(false))</tt>, it loses the mouse grab.</li>
<li>If the item is removed from the scene, it loses the mouse grab.</li>
</ul>
<p>If the item loses its mouse grab, the scene will ignore all mouse events until a new item grabs the mouse (i.e&#x2e;, until a new item receives a mouse press event).</p>
<h3 class="fn"><a name="mouseMoveEvent"></a>void QGraphicsScene::mouseMoveEvent ( <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> * <i>mouseEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse move events for the scene.</p>
<p>The default implementation depends on the mouse grabber state. If there is a mouse grabber item, the event is sent to the mouse grabber; otherwise, the event is ignored.</p>
<p>See also <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem::mousePressEvent</a>(), <a href="qgraphicsitem.html#mouseReleaseEvent">QGraphicsItem::mouseReleaseEvent</a>(), <a href="qgraphicsitem.html#mouseDoubleClickEvent">QGraphicsItem::mouseDoubleClickEvent</a>(), and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem::setAcceptedMouseButtons</a>().</p>
<h3 class="fn"><a name="mousePressEvent"></a>void QGraphicsScene::mousePressEvent ( <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> * <i>mouseEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse press events for the scene.</p>
<p>The default implementation depends on the state of the scene. If there is a mouse grabber item, then the event is sent to the mouse grabber. Otherwise, it is forwarded to the topmost item that accepts mouse events at the scene position from the event, and that item promptly becomes the mouse grabber item.</p>
<p>If there is no item at the given position on the scene, the selection area is reset, any focus item loses its input focus, and the event is then ignored.</p>
<p>See also <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem::mousePressEvent</a>() and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem::setAcceptedMouseButtons</a>().</p>
<h3 class="fn"><a name="mouseReleaseEvent"></a>void QGraphicsScene::mouseReleaseEvent ( <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> * <i>mouseEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse release events for the scene.</p>
<p>The default implementation depends on the mouse grabber state. If there is no mouse grabber, the event is ignored. Otherwise, if there is a mouse grabber item, the event is sent to the mouse grabber. If this mouse release represents the last pressed button on the mouse, the mouse grabber item then loses the mouse grab.</p>
<p>See also <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem::mousePressEvent</a>(), <a href="qgraphicsitem.html#mouseMoveEvent">QGraphicsItem::mouseMoveEvent</a>(), <a href="qgraphicsitem.html#mouseDoubleClickEvent">QGraphicsItem::mouseDoubleClickEvent</a>(), and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem::setAcceptedMouseButtons</a>().</p>
<h3 class="fn"><a name="removeItem"></a>void QGraphicsScene::removeItem ( <a href="qgraphicsitem.html">QGraphicsItem</a> * <i>item</i> )</h3>
<p>Removes the item <i>item</i> and all its children from the scene. The ownership of <i>item</i> is passed on to the caller (i.e&#x2e;, <a href="qgraphicsscene.html">QGraphicsScene</a> will no longer delete <i>item</i> when destroyed).</p>
<p>See also <a href="qgraphicsscene.html#addItem">addItem</a>().</p>
<h3 class="fn"><a name="render"></a>void QGraphicsScene::render ( <a href="qpainter.html">QPainter</a> * <i>painter</i>, const <a href="qrectf.html">QRectF</a> &amp; <i>target</i> = QRectF(), const <a href="qrectf.html">QRectF</a> &amp; <i>source</i> = QRectF(), <a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a> <i>aspectRatioMode</i> = Qt::KeepAspectRatio )</h3>
<p>Renders the <i>source</i> rect from scene into <i>target</i>, using <i>painter</i>. This function is useful for capturing the contents of the scene onto a paint device, such as a <a href="qimage.html">QImage</a> (e.g&#x2e;, to take a screenshot), or for printing with <a href="qprinter.html">QPrinter</a>. For example:</p>
<pre> QGraphicsScene scene;
 scene.addItem(...
 ...
 QPrinter printer(QPrinter::HighResolution);
 printer.setPageSize(QPrinter::A4);

 QPainter painter(&amp;printer);
 scene.render(&amp;painter);</pre>
<p>If <i>source</i> is a null rect, this function will use <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>() to determine what to render. If <i>target</i> is a null rect, the dimensions of <i>painter</i>'s paint device will be used.</p>
<p>The source rect contents will be transformed according to <i>aspectRatioMode</i> to fit into the target rect. By default, the aspect ratio is kept, and <i>source</i> is scaled to fit in <i>target</i>.</p>
<p>See also <a href="qgraphicsview.html#render">QGraphicsView::render</a>().</p>
<h3 class="fn"><a name="sceneRectChanged"></a>void QGraphicsScene::sceneRectChanged ( const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted by <a href="qgraphicsscene.html">QGraphicsScene</a> whenever the scene rect changes. The <i>rect</i> parameter is the new scene rectangle.</p>
<p>See also <a href="qgraphicsview.html#updateSceneRect">QGraphicsView::updateSceneRect</a>().</p>
<h3 class="fn"><a name="selectedItems"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsitem.html">QGraphicsItem</a> *&gt; QGraphicsScene::selectedItems () const</h3>
<p>Returns a list of all currently selected items. The items are returned in no particular order.</p>
<p>See also <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>().</p>
<h3 class="fn"><a name="selectionArea"></a><a href="qpainterpath.html">QPainterPath</a> QGraphicsScene::selectionArea () const</h3>
<p>Returns the selection area that was previously set with <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>(), or an empty <a href="qpainterpath.html">QPainterPath</a> if no selection area has been set.</p>
<p>See also <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>().</p>
<h3 class="fn"><a name="selectionChanged"></a>void QGraphicsScene::selectionChanged ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted by <a href="qgraphicsscene.html">QGraphicsScene</a> whenever the selection changes. You can call <a href="qgraphicsscene.html#selectedItems">selectedItems</a>() to get the new list of selected items.</p>
<p>The selection changes whenever an item is selected or unselected, a selection area is set, cleared or otherwise changed, if a preselected item is added to the scene, or if a selected item is removed from the scene.</p>
<p><a href="qgraphicsscene.html">QGraphicsScene</a> emits this signal only once for group selection operations. For example, if you set a selection area, select or unselect a <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>, or if you add or remove from the scene a parent item that contains several selected items, selectionChanged() is emitted only once after the operation has completed (instead of once for each item).</p>
<p>This function was introduced in Qt 4.3.</p>
<p>See also <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>(), <a href="qgraphicsscene.html#selectedItems">selectedItems</a>(), and <a href="qgraphicsitem.html#setSelected">QGraphicsItem::setSelected</a>().</p>
<h3 class="fn"><a name="setFocus"></a>void QGraphicsScene::setFocus ( <a href="qt.html#FocusReason-enum">Qt::FocusReason</a> <i>focusReason</i> = Qt::OtherFocusReason )</h3>
<p>Sets focus on the scene by sending a <a href="qfocusevent.html">QFocusEvent</a> to the scene, passing <i>focusReason</i> as the reason. If the scene regains focus after having previously lost it while an item had focus, the last focus item will receive focus with <i>focusReason</i> as the reason.</p>
<p>If the scene already has focus, this function does nothing.</p>
<p>See also <a href="qgraphicsscene.html#hasFocus">hasFocus</a>(), <a href="qgraphicsscene.html#clearFocus">clearFocus</a>(), and <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>().</p>
<h3 class="fn"><a name="setFocusItem"></a>void QGraphicsScene::setFocusItem ( <a href="qgraphicsitem.html">QGraphicsItem</a> * <i>item</i>, <a href="qt.html#FocusReason-enum">Qt::FocusReason</a> <i>focusReason</i> = Qt::OtherFocusReason )</h3>
<p>Sets the scene's focus item to <i>item</i>, with the focus reason <i>focusReason</i>, after removing focus from any previous item that may have had focus.</p>
<p>If <i>item</i> is 0, or if it either does not accept focus (i.e&#x2e;, it does not have the <a href="qgraphicsitem.html#GraphicsItemFlag-enum">QGraphicsItem::ItemIsFocusable</a> flag enabled), or is not visible or not enabled, this function only removes focus from any previous focusitem.</p>
<p>If item is not 0, and the scene does not currently have focus (i.e&#x2e;, <a href="qgraphicsscene.html#hasFocus">hasFocus</a>() returns false), this function will call <a href="qgraphicsscene.html#setFocus">setFocus</a>() automatically.</p>
<p>See also <a href="qgraphicsscene.html#focusItem">focusItem</a>(), <a href="qgraphicsscene.html#hasFocus">hasFocus</a>(), and <a href="qgraphicsscene.html#setFocus">setFocus</a>().</p>
<h3 class="fn"><a name="setSelectionArea"></a>void QGraphicsScene::setSelectionArea ( const <a href="qpainterpath.html">QPainterPath</a> &amp; <i>path</i> )</h3>
<p>Sets the selection area to <i>path</i>. All items within this area are immediately selected, and all items outside are unselected. You can get the list of all selected items by calling <a href="qgraphicsscene.html#selectedItems">selectedItems</a>().</p>
<p>For an item to be selected, it must be marked as <i>selectable</i> (<a href="qgraphicsitem.html#GraphicsItemFlag-enum">QGraphicsItem::ItemIsSelectable</a>).</p>
<p>See also <a href="qgraphicsscene.html#clearSelection">clearSelection</a>() and <a href="qgraphicsscene.html#selectionArea">selectionArea</a>().</p>
<h3 class="fn"><a name="setSelectionArea-2"></a>void QGraphicsScene::setSelectionArea ( const <a href="qpainterpath.html">QPainterPath</a> &amp; <i>path</i>, <a href="qt.html#ItemSelectionMode-enum">Qt::ItemSelectionMode</a> <i>mode</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Sets the selection area to <i>path</i> using <i>mode</i> to determine if items are included in the selection area.</p>
<p>This function was introduced in Qt 4.3.</p>
<p>See also <a href="qgraphicsscene.html#clearSelection">clearSelection</a>() and <a href="qgraphicsscene.html#selectionArea">selectionArea</a>().</p>
<h3 class="fn"><a name="update"></a>void QGraphicsScene::update ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>w</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>h</i> )</h3>
<p>This convenience function is equivalent to calling update(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>));</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="update-2"></a>void QGraphicsScene::update ( const <a href="qrectf.html">QRectF</a> &amp; <i>rect</i> = QRectF() )&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Schedules a redraw of the area <i>rect</i> on the scene.</p>
<p>See also <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>() and <a href="qgraphicsscene.html#changed">changed</a>().</p>
<h3 class="fn"><a name="views"></a><a href="qlist.html">QList</a>&lt;<a href="qgraphicsview.html">QGraphicsView</a> *&gt; QGraphicsScene::views () const</h3>
<p>Returns a list of all the views that display this scene.</p>
<p>See also <a href="qgraphicsview.html#scene">QGraphicsView::scene</a>().</p>
<h3 class="fn"><a name="wheelEvent"></a>void QGraphicsScene::wheelEvent ( <a href="qgraphicsscenewheelevent.html">QGraphicsSceneWheelEvent</a> * <i>wheelEvent</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>This event handler, for event <i>wheelEvent</i>, can be reimplemented in a subclass to receive mouse wheel events for the scene.</p>
<p>By default, the event is delivered to the topmost visible item under the cursor. If ignored, the event propagates to the item beneath, and again until the event is accepted, or it reaches the scene. If no items accept the event, it is ignored.</p>
<p>See also <a href="qgraphicsitem.html#wheelEvent">QGraphicsItem::wheelEvent</a>().</p>
<h3 class="fn"><a name="width"></a><a href="qtglobal.html#qreal-typedef">qreal</a> QGraphicsScene::width () const</h3>
<p>This convenience function is equivalent to calling <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>().width().</p>
<p>See also <a href="qgraphicsscene.html#height">height</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
